<?php

namespace app\admin\behavior;
use think\Session;
use think\Request;
use think\Cache;
class Rsend
{

     public function run(&$params)
    {
        $getData = $params->getData();//获取输出的数据

        $_modeule = strtolower(Request::instance()->module());
        //当前控制器名称
        $_controller = strtolower(Request::instance()->controller());
        //当前操作名称
        $_action = strtolower(Request::instance()->action());
        $action = $_modeule."/".$_controller."/".$_action;//当前的模型

        $white_list = [
            "admin/message/messagenum",
 "admin/message/his",
 "admin/message/getread",
        ];

        if (in_array($action,$white_list)){
                return false;
        }


        if($_action=="index"){ //不处理列表输出的参数
            return false;
        }
        if($_action=="read"){ //不处理列表输出的参数
            return false;
        }
        if($_action=="tree"){ //不处理列表输出的参数
            return false;
        }

              //登录处理
        $privilegeModel = new \app\admin\model\Privilege();
        $privilegeData = $privilegeModel->select();

        if(empty($privilegeData)){
            return false;
        }

        foreach($privilegeData as $k=>$v){
                    if($v['action'] == $action){
                        $name = $v['title'];
                  if($v['is_config']){ //排除配置组
                            return false;
                        }

                        break;
                    }
        }
        //处理日志机制
        $scan_nameData = w_g("scan_nameData");
        $sysMessageModel  = new \app\admin\model\SysMessage();
        $sidRow = w_g("sidRow");

        $data = [
            "name"=>isset($name)?$name:"暂无模块",
            "action_man"=>$sidRow['id'],
            "code"=>isset($getData['code'])?$getData['code']:0,
            "msg"=>isset($getData['msg'])?$getData['msg']:0,
            "action"=>$action,
            "action_ip"=>Request::instance()->ip(),
            "content"=>isset($scan_nameData)?json_encode($scan_nameData):"暂无请求数据",
        ];
        $sysMessageModel->save($data);
        if($resnd = w_g("resnd")){
            addMessage($resnd['user_id'],$resnd['content']);
        };
        return true;



    }

}

